<template>
  <div class="login">
    <h2>用户登录</h2>
    <div class="login-form">
      <div class="form-item">
        <label>账号：</label>
        <input type="text" v-model="username" placeholder="请输入账号">
      </div>
      <div class="form-item">
        <label>密码：</label>
        <input type="password" v-model="password" placeholder="请输入密码">
      </div>
      <button @click="handleLogin">登录</button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'LoginPage',
  data() {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    handleLogin() {
      if (this.username === 'admin' && this.password === '123456') {
        sessionStorage.setItem('isLogin', 'true')
        sessionStorage.setItem('username', this.username)
        this.$router.push('/')
      } else {
        alert('账号或密码错误！')
      }
    }
  }
}
</script>

<style scoped>
/* .login {
  width: 300px;
  margin: 100px auto;
  padding: 20px;
  border: 1px solid #ddd;
  border-radius: 5px;
}
.form-item {
  margin: 20px 0;
}
.form-item label {
  display: inline-block;
  width: 60px;
}
.form-item input {
  padding: 5px;
  width: 200px;
}
button {
  width: 100%;
  padding: 8px;
  background-color: #42b983;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
} */
</style> 